home *** CD-ROM | disk | FTP | other *** search
/ F1 Licenseware / F1 Licenseware - Volume 1.iso / disks / 049b.dms / 049b.adf / MORE_SOURCE_CODE / Serial_Slave.AMOS / Serial_Slave.amosSourceCode
AMOS Source Code  |  1992-02-26  |  934b  |  50 lines

  1. ' Serial Master/Slave  
  2. ' Routine Closes Serial Channel on exiting 
  3. ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  4. ' Synchronise computers when linked with null-modem cable
  5. ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6.  
  7. ' Steve Pullinger
  8. ' ~~~~~~~~~~~~~~~
  9. ' MASTER= 0 undefined; 1 This computer has control; 2 This computer is slaved
  10. '
  11. MASTER=0
  12. SEND$="SLAVE"
  13. Serial Open 1,0
  14. While MASTER=0
  15.    LISTEN
  16.    SEND
  17. Wend 
  18. If MASTER=1
  19.    Locate 0,0
  20.    Print "I have assumed Control"
  21. End If 
  22. If MASTER=2
  23.    Locate 0,0
  24.    Print "Slaved"
  25. End If 
  26. Serial Close 
  27. Procedure SEND
  28.    Shared SEND$
  29.    Serial Send 1,SEND$
  30.    LOP:
  31.    If Serial Check(1)=-1
  32.       Wait Vbl 
  33.    Else 
  34.       Goto LOP
  35.    End If 
  36. End Proc
  37. Procedure LISTEN
  38.    Shared MASTER,SEND$
  39.    A$=Serial Input$(1)
  40.    If A$<>""
  41.       If A$="SLAVE"
  42.          MASTER=2
  43.          SEND$="OK"
  44.          SEND
  45.       End If 
  46.       If A$="OK"
  47.          MASTER=1
  48.       End If 
  49.    End If 
  50. End Proc